home *** CD-ROM | disk | FTP | other *** search
/ Champak 109 / Vol 109.iso / games / basket_a.swf / scripts / frame_194 / DoAction.as
Text File  |  2008-11-12  |  4KB  |  146 lines

  1. function goNico()
  2. {
  3.    if(_root.balle.launch)
  4.    {
  5.       updateNico();
  6.       _root.balle.oldY = _root.balle._y;
  7.       _root.balle._x += _root.balle.myVitesseX;
  8.       _root.balle._y -= _root.balle.myVitesseY;
  9.       _root.balle._rotation += 1;
  10.       if(_root.balle._y > _root.balle.oldY)
  11.       {
  12.          _root.balle.direction = "bas";
  13.       }
  14.       else
  15.       {
  16.          _root.balle.direction = "haut";
  17.       }
  18.       _root.balle.myVitesseY *= _root.balle.friction;
  19.       _root.balle.myVitesseX *= _root.balle.friction;
  20.       _root.balle.myVitesseY -= _root.balle.gravite;
  21.       if(_root.balle._y >= 320)
  22.       {
  23.          _root.balle._y = 319;
  24.          if(Math.abs(_root.balle.myVitesseY) < 10)
  25.          {
  26.             _root.balle.launch = false;
  27.             if(_root.scoreloose == 0)
  28.             {
  29.                _root.gotoAndStop("ending");
  30.                clearInterval(intervalID);
  31.             }
  32.             else
  33.             {
  34.                _root.play();
  35.             }
  36.          }
  37.          else
  38.          {
  39.             playSound(_root.balle._x,_root.balle.myVitesseY);
  40.          }
  41.          _root.balle.myVitesseY *= -1 * _root.balle.restitution;
  42.          _root.balle.restitution -= 0.1;
  43.          _root.balle.etat = "out";
  44.       }
  45.       if(_root.balle.hitTest(_root.paniertop) && _root.balle._x > 375)
  46.       {
  47.          if(_root.balle.etat != "out")
  48.          {
  49.             _root.balle.myVitesseY *= -1 * _root.balle.restitution;
  50.             _root.balle.resitution -= 0.1;
  51.             _root.balle.myVitesseX += 1;
  52.             _root.filet.play();
  53.          }
  54.       }
  55.       if(_root.balle.hitTest(_root.panier))
  56.       {
  57.          _root.balle.myVitesseX *= -1;
  58.          _root.balle.myVitesseX *= _root.balle.friction;
  59.          if(_root.balle.etat != "out")
  60.          {
  61.             _root.filet.play();
  62.          }
  63.       }
  64.       if(_root.balle.hitTest(_root.panier2))
  65.       {
  66.          _root.balle.myVitesseX *= -1;
  67.          _root.balle.myVitesseX *= _root.balle.friction;
  68.       }
  69.       if(_root.balle._x >= 485 && _root.balle._x < 515 && _root.balle._y >= 180)
  70.       {
  71.          _root.balle._x = 484;
  72.          _root.balle.myVitesseX *= -1;
  73.          _root.balle.myVitesseX *= _root.balle.friction;
  74.          playSound(_root.balle._x,_root.balle.myVitesseX);
  75.       }
  76.       if(_root.balle._x >= 422 && _root.balle._x < 465 && _root.balle._y >= 35 && _root.balle._y <= 100)
  77.       {
  78.          _root.balle._x = 421;
  79.          playSound(_root.balle._x,_root.balle.myVitesseX);
  80.          _root.balle.myVitesseX *= -1;
  81.          _root.balle.myVitesseX *= 0.5 * _root.balle.friction;
  82.       }
  83.       if(_root.balle.hitTest(_root.score) && _root.balle.direction == "bas" && _root.balle.etat != "out" && _root.score.scoreOn == true)
  84.       {
  85.          _root.scoreaff = _root.scoreaff + 1;
  86.          _root.score.scoreOn = false;
  87.          _root.filet.filet2.filet3.play();
  88.       }
  89.    }
  90.    updateAfterEvent();
  91. }
  92. function updateNico()
  93. {
  94.    anglenico = Math.atan2(_root.balle._y - 200,_root.balle._x - _root.nico._x);
  95.    anglenico2 = anglenico / 0.017453292519943295 + 20;
  96.    if(anglenico2 > 80)
  97.    {
  98.       anglenico2 = 80;
  99.    }
  100.    else if(anglenico2 < -60)
  101.    {
  102.       anglenico2 = -60;
  103.    }
  104.    _root.nico.tete._rotation = anglenico2 * 0.2;
  105. }
  106. function playSound(x, speed)
  107. {
  108.    var ballX = x * 100 / 560;
  109.    var pan = -50 + ballX * 2;
  110.    if(x < 0)
  111.    {
  112.       var pan = -100;
  113.    }
  114.    else if(x > 560)
  115.    {
  116.       var pan = 100;
  117.    }
  118.    var maxSpeed = 15;
  119.    var minSpeed = 1;
  120.    var speed = Math.abs(speed);
  121.    var factor = speed / (maxSpeed - minSpeed);
  122.    if(speed < minSpeed)
  123.    {
  124.       var factor = 0;
  125.    }
  126.    var volume = factor * 100;
  127.    if(volume > 0)
  128.    {
  129.       bounce = new Sound(son);
  130.       bounce.attachSound("bounce");
  131.       bounce.setPan(pan);
  132.       bounce.setVolume(volume);
  133.       bounce.start();
  134.    }
  135. }
  136. force = 5;
  137. myAngle = 80;
  138. _root.nico.tete._rotation = 0;
  139. balle._x = random(200) + 100;
  140. nico._x = balle._x;
  141. pointer._x = _root.nico._x + 5;
  142. origAngle = 0.017453292519943295 * myAngle;
  143. var intervalID;
  144. intervalID = setInterval(goNico,20);
  145. stop();
  146.